<template>
    <div>
        <h1>修改</h1>
        <table class="table">
            <tbody>
                <tr>
                    <td>房间号:</td>
                    <td>
                        <input type="text" v-model="data.houseHao">
                    </td>
                </tr>
                <tr>
                    <td>房间名称:</td>
                    <td>
                        <input type="text" v-model="data.houseName">
                    </td>
                </tr>
                <tr>
                    <td>手机号:</td>
                    <td>
                        <input type="text" v-model="data.housePoen">
                    </td>
                </tr>
                <tr>
                    <td>
                        <input type="button" value="修改" @click="Update">
                        <a href="Show">返回列表</a>
                    </td>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue';
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
const router=useRouter();
const route=useRoute();
onMounted(()=>{
    FanTian();
})
const FanTian=()=>{
    var houseId=route.query.houseId;
    axios.get("https://localhost:7187/api/HouseNum/FanTian?houseId="+houseId).then(res=>{
        data.value=res.data;
    })
}
const data=ref({
    "houseId": 0,
    "userName": "",
    "userPwd": "",
    "houseHao": "",
    "houseName": "",
    "housePoen": "",
    "houseSex": ""
})
const Update=()=>{
    axios.post("https://localhost:7187/api/HouseNum/Update",data.value).then(res=>{
        if(res.data>0)
    {
        alert("修改成功！");
        location.href="Show";
    }
    else{
        alert("修改失败！");
        return;
    }
    })
}
</script>

<style scoped>

</style>